package com.example.demo.controller;

import com.example.demo.ao.ApprovalAo;
import com.example.demo.ao.User;
import com.example.demo.service.ApprovalService;
import com.example.demo.vo.ApprovalRecordVo;
import com.example.demo.vo.ApprovalVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/approval")
@Slf4j
public class ApprovalController {


    @Autowired
    private ApprovalService approvalService;


    @PostMapping("/create")
    public String insertApprovalInfo(@RequestBody ApprovalAo approvalAo){
        return approvalService.insertApprovalInfo(approvalAo);
    }


    //审批流程
    @PostMapping("/low")
    public String insertApprovalLow(@RequestBody ApprovalAo approvalAo, User user){
        return approvalService.insertApprovalLow(approvalAo, user);
    }


    @PostMapping("get/info/user")
    public List<ApprovalVo > getApprovalInfoByUserId(@RequestBody ApprovalAo ApprovalAo){
        return approvalService.getApprovalInfoByUserId(ApprovalAo.getUserId());
    }


    @PostMapping("/get/record")
    public List<ApprovalRecordVo> getApprovalRecord(@RequestBody  Integer userId){
        return approvalService.getApprovalRecord(userId);
    }
}
